<?php
namespace api\xcx\controller;
/**
 *  Order.php 预约控制器
 *
 * @copyright			(C) 2014-2018 ShengTeng
 * @lastmodify			2018-05-21
 */
use think\Cache;
use think\Loader;
use think\Db;
use think\Request;
use think\Controller;
use think\config;
class Order extends Base
{
   /**
 * @api {POST} Order/appoint 上门预约
 * @apiVersion 1.0.0
 * @apiGroup 上门订单
 *
 * @apiParam {String} token  用户token
 * @apiParam {String} time 预约时间
 * @apiParam {String} name 姓名
 * @apiParam {String} phone 电话
 * @apiParam {String} address 地址
 *
 * @apiSuccess {Int} code 返回码
 * @apiSuccess {String} message  提示信息
 * @apiSuccess {Object} data  返回数据
 *
 * @apiSuccessExample {json} Success-Response:
 *     HTTP/1.1 200 OK
 *     {
 *          "code":0,
 *          "message":"",
 *          "data":{
 *              orderNumber 订单号
 *          }
 *      }
 */
    public function appoint(Request $request){
        $params=$request->param();
        //token
        $token = $this->checkParam($params['token'],'token',true);
        // time
        $time = $this->checkParam($params['time'],'time',true);
        // name
        $name = $this->checkParam($params['name'],'name',true);
        // phone
        $phone = $this->checkParam($params['phone'],'phone',true);
        // address
        $address = $this->checkParam($params['address'],'address',true);
        // 检测用户
        $userId = $this->getUserId($token);
      
        $data['orderTime'] = $time;
        $data['orderName'] = $name;
        $data['orderPhone'] = $phone;
        $data['orderAddress'] = $address;
        $data['userId'] = $userId;
      
      	$user = Model('user');
      	$userInfo = $user->getInfoById($userId);
      	if($userInfo['userStatus'] != 2){
           return json(returnAjax(null,'您不是会员','1'));
        }

      
      
      
        // 生成预约订单
        $appointment = Model('Appointment');
        $res = $appointment->createOrder($data);
        if($res){
            return json(returnAjax($res));
        }else{
            return json(returnAjax(null,'订单生成失败','-1'));
       
        }
    }
   
   /**
 * @api {POST} Order/orderShop 到店预约
 * @apiVersion 1.0.0
 * @apiGroup 门店订单
 *
 * @apiParam {String} token  用户token
 * @apiParam {Int} shopId  门店id
 *
 * @apiSuccess {Int} code 返回码
 * @apiSuccess {String} message  提示信息
 * @apiSuccess {Object} data  返回数据
 *
 * @apiSuccessExample {json} Success-Response:
 *     HTTP/1.1 200 OK
 *     {
 *          "code":0,
 *          "message":"",
 *          "data":{
 *          }
 *      }
 */

public function orderShop(Request $request){
    $params=$request->param();
    if(!isset($params['token'])){
        return json(returnAjax('','缺少参数token','1'));
    }else if($params['token']==""){
        return json(returnAjax('','token不可为空','1'));
    }
    $token= $params['token'];//用户token
    if(!isset($params['shopId'])){
        return json(returnAjax('','缺少参数shopId','1'));
    }else if($params['shopId']==""){
        return json(returnAjax('','shopId不可为空','1'));
    }
    $shopId= $params['shopId'];//门店id
    // 检测门店是否存在
    $isShop = $this->selShop($shopId);
    if(!$isShop){
        return json(returnAjax('','店铺不存在','1'));
    }
    // 获取用户
    // 1.根据token获取用户id
    $user = Model('User');
    $userInfo = $user->getId($token);
    if(!$userInfo){
        return json(returnAjax('','用户不存在','10'));
    }
    $userId = $userInfo['userId'];
    if(!$userId){
        return json(returnAjax($userInfo,'未获取到用户信息','-1'));
    }
      	$userInfso = $user->getInfoById($userId);
      	if($userInfso['userStatus'] != 2){
           return json(returnAjax(null,'您不是会员','1'));
        }

    // 用户是否有预约
    $order = Model('Order');
    $is_order = $order->ordering($userId);
    if($is_order){
        return json(returnAjax(null,'您已有预约','1'));
    }
    // 生成预约门店订单
    $order = Model('Order');
    $data['shopId'] = $shopId;
    $data['userId'] = $userId;
    $data['type'] = 2;
    $data['status'] = 1;
    $addOrder = $order->addOrderShop($data);
    if($addOrder){
        $server = Model('ShopServer');
        $shopInfo = $server->selDetail($shopId);
        $shopInfo['orderNumber'] = $addOrder['orderNumber'];

        return json(returnAjax($shopInfo));
    }else{
        return json(returnAjax(null,'预约到店失败','-1'));
    }
}




   /**
 * @api {POST} Order/selRecord 美甲记录
 * @apiVersion 1.0.0
 * @apiGroup 订单
 *
 * @apiParam {String} token  用户token
 * @apiParam {Int} status 状态值 0全部,1预约中,2服务中,3已完成,4申请退款中,5已退款,6已取消
 * @apiParam {Int} page 页数,默认1
 *
 * @apiSuccess {Int} code 返回码
 * @apiSuccess {String} message  提示信息
 * @apiSuccess {Object} data  返回数据
 *
 * @apiSuccessExample {json} Success-Response:
 *     HTTP/1.1 200 OK
 *     {
 *          "code":0,
 *          "message":"",
 *          "data":{
 *              "orderNumber"       //订单号,
 *               "shopId"           //店铺id,
 *               "discountMoney"    //支付金额,
 *               "status"           //订单状态,
 *               "orderNo"          //预约号,
 *               "commodityId"      //项目id,
 *               "shopName"         //店铺名称,
 *               "orderTime"        //预约时间,
 *               "orderAddress"     //预约地址,
 *               "orderName"        //姓名,
 *               "orderPhone"       //电话,
 *               "goods_name"       //项目名称
 *               "type"             //类型,1上门,2到达
 *          }
 *      }
 */

    public function selRecord(Request $request){
        $params=$request->param();
        // 验证字段
        
        if(!isset($params['token'])){
            return json(returnAjax('','缺少参数token','1'));
        }
        $token= $params['token'];//用户token
        $status = null;
        if(isset($params['status'])){
            if($params['status'] != '0' && $params['status'] !='1' && $params['status'] !='2' && $params['status'] !='3' && $params['status'] !='4' && $params['status'] !='5' && $params['status'] !='6' ){
                return json(returnAjax('','status值错误','1'));
            }else{
                $status = $params['status'];
            }
        }
        
        if(!isset($params['page'])){
            return json(returnAjax('','缺少参数page','1'));
        }
        $page = $params['page'];

        // 1.根据token获取用户id
        $user = Model('User');
        $userInfo = $user->getId($token);
        if(!$userInfo){
            return json(returnAjax('','用户不存在','10'));
        }
        $userId = $userInfo['userId'];
        if(!$userId){
            return json(returnAjax($userInfo,'未获取到用户id','1'));
        }

        $order = Model('Order');
        $res = $order->selRecord($userId,$status,$page);
        if($res || $res == []){

            if($res!=[]){
                $shop_config = Model('ShopConfig');
                for($k=0;$k<count($res);$k++){
                    $shop_goodsId = $res[$k]['commodityId'];
                    $shopId = $res[$k]['shopId'];
                    $goods_name = array();
                    $goods_arr = explode(',',$shop_goodsId);
                    for($i=0;$i<count($goods_arr);$i++){
                        $goodsInfo = $shop_config->selById($goods_arr[$i],$shopId);
                        array_push($goods_name,$goodsInfo['name']);
                    }
                    $res[$k]['goods_name'] = implode(',',$goods_name);
                }
            }

            return json(returnAjax($res));
        }else{
            return json(returnAjax('','系统错误','-1'));
        }
    }

   /**
 * @api {POST} Order/isOrdering 是否存在进行中的预约记录
 * @apiVersion 1.0.0
 * @apiGroup 门店订单
 *
 * @apiParam {String} token  用户token
 *
 * @apiSuccess {Int} code 返回码
 * @apiSuccess {String} message  提示信息
 * @apiSuccess {Object} data  返回数据
 *
 * @apiSuccessExample {json} Success-Response:
 *     HTTP/1.1 200 OK
 *     {
 *          "code":0,
 *          "message":"",
 *          "data":{
 *              shopId ,有就返回店铺id,没有就为空
 *          }
 *      }
 */
    public function isOrdering(Request $request){
        $params=$request->param();
        if(!isset($params['token'])){
            return json(returnAjax('','缺少参数token','1'));
        }
        $token= $params['token'];//用户token
        // 根据token获取userId
        $userId = $this->getUserId($token);
        $order = Model('Order');
        $is_order = $order->ordering($userId);
        if($is_order || $is_order==[]){
            return json(returnAjax($is_order));
        }else{
            return json(returnAjax('','系统异常','-1'));
        }
    }

   /**
 * @api {POST} Order/userUpdOrder 对上门订单进行修改
 * @apiVersion 1.0.0
 * @apiGroup 上门订单
 *
 * @apiParam {String} token  用户token
 * @apiParam {Int} orderNumber  订单号
 * @apiParam {String} time 预约时间
 * @apiParam {String} name 姓名
 * @apiParam {String} phone 电话
 * @apiParam {String} address 地址
 *
 * @apiSuccess {Int} code 返回码
 * @apiSuccess {String} message  提示信息
 * @apiSuccess {Object} data  返回数据
 *
 * @apiSuccessExample {json} Success-Response:
 *     HTTP/1.1 200 OK
 *     {
 *          "code":0,
 *          "message":"",
 *          "data":{
 *              
 *          }
 *      }
 */
    public function userUpdOrder(Request $request){
        $params=$request->param();
        if(!isset($params['token'])){
            return json(returnAjax('','缺少参数token','1'));
        }
        $token = $params['token'];
        //验证订单号
        if(!isset($params['orderNumber'])){
            return json(returnAjax('','缺少参数orderNumber','1'));
        }
        $orderNumber = $params['orderNumber'];
        if(!isset($params['time'])){
            return json(returnAjax('','缺少参数time','1'));
        }
        $time = $params['time'];//预约时间


        if(!isset($params['name'])){
            return json(returnAjax('','缺少参数name','1'));
        }
        $name = $params['name'];//姓名

        if(!isset($params['phone'])){
            return json(returnAjax('','缺少参数phone','1'));
        }
        $phone = $params['phone'];//电话

        if(!isset($params['address'])){
            return json(returnAjax('','缺少参数address','1'));
        }
        $address = $params['address'];//地址
        $userId = $this->getUserId($token);
        // 根据订单号修改订单扩展的信息,如果当前订单的预约状态状态不为1,则无法修改
        $orderEx = Model('Appointment');
        $orderInfoEx = $orderEx->order_info($orderNumber);
        if(!$orderInfoEx){
            return json(returnAjax('','未找到该订单','1'));
        }
        $orderId = $orderInfoEx['appointId'];

        $order = Model('Order');

        $orderInfo = $order->sel_info_appointId($orderId);
        if(!$orderInfo){
            return json(returnAjax('','未找到该预约订单','1'));
        }
        $status = $orderInfo['status'];
        if($status!=1){
            if($status== null || $status== ""){
                return json(returnAjax('','该订单未支付,无法修改','1'));
            }
            switch ($status) {
                case '2':
                    return json(returnAjax('','服务已开始,无法修改','1'));
                    break;
                case '3':
                    return json(returnAjax('','服务已完成,无法修改','1'));
                    break;
                case '4':
                    return json(returnAjax('','服务正在取消中,无法修改','1'));
                    break;
                case '5':
                    return json(returnAjax('','服务已取消,无法修改','1'));
                    break;
            }
            
        }
        // 修改信息
        $orderExtraData['orderTime'] = $time;
        $orderExtraData['orderName'] = $name;
        $orderExtraData['orderPhone'] = $phone;
        $orderExtraData['orderAddress'] = $address;
        $updOrderEx = $orderEx->updOrder($orderExtraData,$orderNumber);
        if($updOrderEx){
            return json(returnAjax());
        }else{
            return json(returnAjax('','预约信息修改失败','-1'));
        }
    }


       /**
     * @api {POST} Order/cancelOrder 取消预约
     * @apiVersion 1.0.0
     * @apiGroup 门店订单
     *
     * @apiParam {String} token  用户token
     * @apiParam {Int} orderNumber  订单号
     *
     * @apiSuccess {Int} code 返回码
     * @apiSuccess {String} message  提示信息
     * @apiSuccess {Object} data  返回数据
     *
     * @apiSuccessExample {json} Success-Response:
     *     HTTP/1.1 200 OK
     *     {
     *          "code":0,
     *          "message":"",
     *          "data":{
     *              
     *          }
     *      }
     */
    public function cancelOrder(Request $request){
        $params=$request->param();
        if(!isset($params['token'])){
            return json(returnAjax('','缺少参数token','1'));
        }
        $token = $params['token'];
        //验证订单号
        if(!isset($params['orderNumber'])){
            return json(returnAjax('','缺少参数orderNumber','1'));
        }
        $orderNumber = $params['orderNumber'];
        $userId = $this->getUserId($token);
        $order = Model("Order");
        // 检查订单状态
        $orderInfo = $order->order_info($orderNumber);
        $status = $orderInfo['status'];
        if(!$orderInfo){
            return json(returnAjax('','未找到该订单','1'));
        }
        if($status!=1){
            if($status== null || $status== ""){
                return json(returnAjax('','未预约,无法取消','1'));
            }
        }
        //取消预约,修改status为6
        $cancel = $order->cancelOrder($userId,$orderNumber);
        if($cancel){
            return json(returnAjax());
        }else{
            return json(returnAjax('','取消失败,请联系客服人员','1'));
        }
    }


     /**
     * @api {POST} Order/orderTodoor 上门订单列表
     * @apiVersion 1.0.0
     * @apiGroup 上门订单
     *
     * @apiParam {Int} token 员工token
     * @apiParam {Int} shopId  门店id
     * @apiParam {Int} status  1未接订单,2我的订单
     * @apiParam {Int} page  页数默认1
     *
     * @apiSuccess {Int} code 返回码
     * @apiSuccess {String} message  提示信息
     * @apiSuccess {Object} data  返回数据
     *
     * @apiSuccessExample {json} Success-Response:
     *     HTTP/1.1 200 OK
     *     {
     *          "code":0,
     *          "message":"",
     *          "data":{
     *                  "id" 订单id
     *                  "commodityId" 项目id
     *                  "orderNumber" 订单号
     *                  "shopId" 店铺id
     *                  "orderName" 用户姓名
     *                  "orderPhone" 用户手机号
     *                  "orderTime" 预约时间
     *                  "orderAddress" 预约地址 
     *                  "userId": 用户id
     *                  "goods_name" 项目名称
     *          }
     *      }
     */
    public function orderTodoor(Request $request){
        $params=$request->param();
        // 验证参数
        if(!isset($params['token'])){
            return json(returnAjax('','缺少参数token','1'));
        }
        $token = $params['token'];


        if(!isset($params['shopId'])){
            return json(returnAjax('','缺少参数shopId','1'));
        }
        $shopId = $params['shopId'];
        if(!isset($params['status'])){
            return json(returnAjax('','缺少参数status','1'));
        }
        $status = $params['status'];
        if(!isset($params['page'])){
            return json(returnAjax('','缺少参数page','1'));
        }
        $page = $params['page'];
        if($status !=1 &&  $status!=2){
            return json(returnAjax('','status值有误','1'));
        }
        if($page<=0){
            return json(returnAjax('','page值有误,要求大于0','1'));
        }
        // 查看员工是否存在
        $isStaff = $this->selStaff($token);
        if(!$isStaff){
            return json(returnAjax('','员工不存在',10));
        }
        $status--;
        $staffId = $isStaff['userId'];
        // 查询所属状态订单
        $order = Model('Order');
        $res = $order->orderListDoor($staffId,$status,$page);
        if($res || $res==[]){
            if($res){
                $shop_config = Model('ShopConfig');
                for($k=0;$k<count($res);$k++){
                    $shop_goodsId = $res[$k]['commodityId'];
                    $shopId = $res[$k]['shopId'];

                    $goods_name = array();
                    $goods_arr = explode(',',$shop_goodsId);
                    for($i=0;$i<count($goods_arr);$i++){
                        $goodsInfo = $shop_config->selById($goods_arr[$i],$shopId);
                        array_push($goods_name,$goodsInfo['name']);
                    }
                    $res[$k]['goods_name'] = implode(',',$goods_name);
                }
            }
            return json(returnAjax($res));
        }else{
            return json(returnAjax('','系统有误','-1'));
        }
    }
     /**
     * @api {POST} Order/orderToShop 到店订单列表
     * @apiVersion 1.0.0
     * @apiGroup 门店订单
     *
     * @apiParam {Int} shopId  门店id
     * @apiParam {Int} page  页数默认1
     *
     * @apiSuccess {Int} code 返回码
     * @apiSuccess {String} message  提示信息
     * @apiSuccess {Object} data  返回数据
     *
     * @apiSuccessExample {json} Success-Response:
     *     HTTP/1.1 200 OK
     *     {
     *          "code":0,
     *          "message":"",
     *          "data":{
     *           "orderNumber" 订单号
     *           "shopId": 店铺id
     *           "orderNo": 用户序号
     *           "userName": 用户昵称
     *           "userPhoto": 照片
     *           "trueName": 用户名称
     *             "userId": 用户id
     *          }
     *      }
     */
    public function orderToShop(Request $request){
        $params=$request->param();
        // 验证参数
        if(!isset($params['page'])){
            return json(returnAjax('','缺少参数page','1'));
        }
        $page = $params['page'];
        if(!isset($params['shopId'])){
            return json(returnAjax('','缺少参数shopId','1'));
        }
        $shopId = $params['shopId'];
        // 查看店铺是否存在
        $isShop = $this->selShop($shopId);
        if(!$isShop){
            return json(returnAjax('','店铺不存在','1'));
        }
        if($page<=0){
            return json(returnAjax('','page值有误,要求大于0','1'));
        }
        $order = Model('Order');
        $res = $order->orderListShop($shopId,$page);
        if($res || $res ==[]){
            return json(returnAjax($res));
        }else{
            return json(returnAjax('','系统错误','-1'));
        }
    }
    /**
     * @api {POST} Order/staffOperateOrder 员工操作上门订单
     * @apiVersion 1.0.0
     * @apiGroup 订单
     *
     * @apiParam {Int} shopId  门店id
     * @apiParam {Int} token  员工token
     * @apiParam {Int} orderNumber  订单号
     * @apiParam {Int} type 操作类型  1接单,2取消单,3开始服务
     *
     * @apiSuccess {Int} code 返回码
     * @apiSuccess {String} message  提示信息
     * @apiSuccess {Object} data  返回数据
     *
     * @apiSuccessExample {json} Success-Response:
     *     HTTP/1.1 200 OK
     *     {
     *          "code":0,
     *          "message":"",
     *          "data":{

     *          }
     *      }
     */
    public function staffOperateOrder(Request $request){
        $params=$request->param();
        // 验证参数
        if(!isset($params['shopId'])){
            return json(returnAjax('','缺少参数shopId','1'));
        }
        $shopId = $params['shopId'];
        if(!$shopId || $shopId==""){
            return json(returnAjax('','shopId不可为空','1'));
        }
        if(!isset($params['token'])){
            return json(returnAjax('','缺少参数token','1'));
        }
        $token = $params['token'];
        if(!isset($params['orderNumber'])){
            return json(returnAjax('','缺少参数orderNumber','1'));
        }
        $orderNumber = $params['orderNumber'];
        if(!isset($params['type'])){
            return json(returnAjax('','缺少参数type','1'));
        }
        $type = $params['type'];
       // 查看员工是否存在
       $isStaff = $this->selStaff($token);
       if(!$isStaff){
           return json(returnAjax('','员工不存在','10'));
       }
       $staffId = $isStaff['userId'];
        // 查看店铺是否存在
        $isShop = $this->selShop($shopId);
        if(!$isShop){
            return json(returnAjax('','店铺不存在','1'));
        }
        // 查看员工是否上线
        $staffstatus = Model('StaffStatus');
        $isWorking = $staffstatus->selWorking($staffId);
        if(!$isWorking){
            return json(returnAjax('','请先上班','1'));
        }
        // 查看订单,1.是否存在,2.是否被接
        $order = Model('Order');
        $selOrder = $order->order_info($orderNumber);
        if(!$selOrder){
            return json(returnAjax('','订单不存在','1'));
        }else{
            $orderStaff = $selOrder['staffId'];
            $orderStatus = $selOrder['status'];
            switch ($type) {
                case '1':
                    if($orderStaff>0){
                        return json(returnAjax('','订单已被别人接走,无法操作','1'));
                    }
                    $staffTakeOrder = $order->staffTakeOrder($orderNumber,$staffId,$shopId);
                    if($staffTakeOrder){
                        return json(returnAjax());
                    }else{
                        return json(returnAjax('','系统异常1','-1'));
                    }
                break;
                case '2':
                    if($orderStaff==0 || $orderStaff!=$staffId){
                        return json(returnAjax('','未接该订单,无法操作2','1'));
                    }
                    $staffCancelOrder = $order->staffCancelOrder($orderNumber,$shopId);
                    if($staffCancelOrder){
                        return json(returnAjax());
                    }else{
                        return json(returnAjax('','系统异常2','-1'));
                    }
                break;
                case '3':
                    if($orderStaff==0 || $orderStaff!=$staffId){
                        return json(returnAjax('','未接该订单,无法操作3','1'));
                    }
                    $staffServiceOrder = $order->staffServerDoorOrder($orderNumber,$shopId);
                    if($staffServiceOrder){
                        return json(returnAjax());
                    }else{
                        return json(returnAjax('','系统异常3','-1'));
                    }
                break;
            }
        }
    }


    /**
     * @api {POST} Order/staffOrderShop 员工开始服务门店订单
     * @apiVersion 1.0.0
     * @apiGroup 门店订单
     *
     * @apiParam {Int} shopId  门店id
     * @apiParam {Int} token  员工token
     * @apiParam {Int} orderNumber  订单号
     *
     * @apiSuccess {Int} code 返回码
     * @apiSuccess {String} message  提示信息
     * @apiSuccess {Object} data  返回数据
     *
     * @apiSuccessExample {json} Success-Response:
     *     HTTP/1.1 200 OK
     *     {
     *          "code":0,
     *          "message":"",
     *          "data":{

     *          }
     *      }
     */
    public function staffOrderShop(Request $request){
        $params=$request->param();
        //token
        $token = $this->checkParam($params['token'],'token',true);
        //shopId 
        $shopId = $this->checkParam($params['shopId'],'shopId',true);
        // orderNumber
        $orderNumber = $this->checkParam($params['orderNumber'],'orderNumber',true);
        // 查看店铺是否存在
        $isShop = $this->selShop($shopId);
        // 查看订单是否存在
        $isOrder = $this->selOrder($orderNumber);
        // 查看员工是否存在
        $staffId = $this->selStaff($token);
        $order = Model('Order');
        $res = $order->staffServiceOrder($orderNumber,$shopId,$staffId['userId']);
        if($res['code'] == 0){
            return json(returnAjax());
        }else{
            return json(returnAjax('',$res['message'],'-1'));
        }
    }



     /**
     * @api {POST} Order/staffcOrderShop 员工取消服务门店订单
     * @apiVersion 1.0.0
     * @apiGroup 门店订单
     *
     * @apiParam {Int} shopId  门店id
     * @apiParam {Int} token  员工token
     * @apiParam {Int} orderNumber  订单号
     *
     * @apiSuccess {Int} code 返回码
     * @apiSuccess {String} message  提示信息
     * @apiSuccess {Object} data  返回数据
     *
     * @apiSuccessExample {json} Success-Response:
     *     HTTP/1.1 200 OK
     *     {
     *          "code":0,
     *          "message":"",
     *          "data":{

     *          }
     *      }
     */
    public function staffcOrderShop(Request $request){
        $params=$request->param();
        //token
        $token = $this->checkParam($params['token'],'token',true);
        //shopId 
        $shopId = $this->checkParam($params['shopId'],'shopId',true);
        // orderNumber
        $orderNumber = $this->checkParam($params['orderNumber'],'orderNumber',true);
        // 查看店铺是否存在
        $isShop = $this->selShop($shopId);
        // 查看订单是否存在
        $isOrder = $this->selOrder($orderNumber);
        // 查看员工是否存在
        $staffId = $this->selStaff($token);
        $order = Model('Order');
        $res = $order->staffCServiceOrder($orderNumber,$shopId,$staffId['userId']);
        if($res['code'] == 0){
            return json(returnAjax());
        }else{
            return json(returnAjax('',$res['message'],'-1'));
        }
    }







    /**
     * @api {POST} Order/selStatus 根据订单号查看订单状态
     * @apiVersion 1.0.0
     * @apiGroup 订单
     *
     * @apiParam {Int} orderNumber  订单号
     *
     * @apiSuccess {Int} code 返回码
     * @apiSuccess {String} message  提示信息
     * @apiSuccess {Object} data  返回数据
     *
     * @apiSuccessExample {json} Success-Response:
     *     HTTP/1.1 200 OK
     *     {
     *          "code":0,
     *          "message":"",
     *          "data":{
     *              "status": 订单状态 0:无状态 1：预约，2：开始服务，3：已完成 ,4退款中,5已退款,6,用户取消(门店)
     *              payStatus  支付状态,1未支付,2已支付
     *             reward 打赏
     *             discountMoney 支付金额
     *             userName 用户昵称
     *             trueName 用户名字
     *             userPhoto 用户照片
     *             userId 用户id
     *             userStatus 用户状态 1,非vip,2vip
     *          }
     *      }
     */
    public function selStatus(Request $request){
        $params=$request->param();
        // orderNumber
        $orderNumber = $this->checkParam($params['orderNumber'],'orderNumber',true);
        // 查看订单是否存在
        $isOrder = $this->selOrder($orderNumber);
        $order = Model('Order');
        $res = $order->selStatusByNm($orderNumber);
        if($res){
            return json(returnAjax($res));
        }else{
            return json(returnAjax('','系统错误','-1'));
        }
    }   
}
